package com.common.utils;

import java.lang.reflect.Type;

import com.google.gson.Gson;
import com.google.gson.GsonBuilder;


public final class JsonUtil {

	 private JsonUtil(){}  
     

	    public static String toJson(Object obj) {  
	        Gson gson = new Gson();  
	        return gson.toJson(obj);  
	    }  
	  
 
	    public static <T> T fromJson(String str, Type type) {  
	        Gson gson = new Gson();  
	        return gson.fromJson(str, type);  
	    }  
	  

	    public static <T> T fromJson(String str, Class<T> type) {  
	        Gson gson = new Gson();  
	        return gson.fromJson(str, type);  
	    }  
	    
	    public static <T> T fromJsonDateFromat(String str,String dateFromat, Class<T> type) {  
	        Gson gson = new GsonBuilder().setDateFormat(dateFromat).create();  
	        return gson.fromJson(str, type);  
	    }  
}
